<?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use common\components\widgets\Datetimepicker;

Datetimepicker::widget(['timepicker' => 'true', 'datepicker' => 'false', 'format' => 'H:i', 'step' => '5']);
?>
<div class="yx-radius2">
    <?php $form = ActiveForm::begin(['enableAjaxValidation' => true, 'enableClientValidation' => false, 'options' => ['class' => 'form-validate']]); ?>
    <table width="100%" class="table-form">
        <tr>
            <th class="zx-goods-table"><?= $model->attributeLabels()['card_number']; ?></th>
            <td><?= $form->field($model, 'card_number', ['template' => '{input}{error}{hint}'])->textInput(['style' => 'width:180px', 'class' => 'input-text']) ?></td>
        </tr>
    </table>
    <div class="yx-submit-box" style="display: none">
        <?= \yii\helpers\Html::buttonInput( '提交', ['class' => "button yx-submit", 'id' => 'dosubmit']) ?>
    </div>
</div>

<?php \yii\widgets\ActiveForm::end(); ?>
<?php
$js = <<<JS
   $(document).on('click','#dosubmit',function(){
       var tmp = true;
       $('.extend_required').each(function(e){
           var val = $.trim($(this).val());
           var tr = $(this).parents('tr');
           var title = tr.find('.zx-goods-table').html();
           if(val == ''){
               $(this).next().html(title+'不能为空');
               tmp = false;
           }
      });
       if(tmp){
           $('.form-validate').submit();
       }
   });
       $('.extend_required').blur(function(e){
           var val = $.trim($(this).val());
           var tr = $(this).parents('tr');
           var title = tr.find('.zx-goods-table').html();
           if(val == ''){
               $(this).next().html(title+'不能为空');
           }else {
               $(this).next().html('');
           }
      
   });
    
JS;
$this->registerJS($js);
?>
